Module.c("plugin.basicLoginDialog");

$(document).ready(function(){plugin.basicLoginDialog.init();});


plugin.basicLoginDialog.init = function(){
	plugin.basicLoginDialog.initData();
	plugin.basicLoginDialog.renderPage();
	plugin.basicLoginDialog.bindEvent();
}


plugin.basicLoginDialog.initData = function(){
	
}

plugin.basicLoginDialog.renderPage=function(){
	
	$('#plugin_loginDialog').dialog({ 
		autoOpen: false,
		modal   : true,
		width   : 380,
		title   : '用户登录',
		resizable:false,
		buttons:{
			"登录":plugin.basicLoginDialog.submitLogin,
			"取消":plugin.basicLoginDialog.closeMe
		}
	});
	
}

plugin.basicLoginDialog.bindEvent=function(){
	
}

plugin.basicLoginDialog.closeMe = function(){
	$('#plugin_loginDialog').dialog('close');
}

plugin.basicLoginDialog.submitLogin = function(){
	var formData = $('#plugin_loginForm').serialize();
	$.post(webappName+"/auth/basic/doLogin",formData,plugin.basicLoginDialog.onLoginCallBack,"json");
}

plugin.basicLoginDialog.onLoginCallBack = function(responseVO){
	var result = responseVO.executeResult;
	if (result){
		plugin.basicLoginDialog.closeMe();
	}else{
		$(document).trigger(responseVO.errCode);
		alert('errorLogin');
	}
}
